<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
	<meta charset="utf-8" />
	<title>驴妈妈流立方</title>
	<meta name="description" content="overview &amp; stats" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" />
	<!-- bootstrap & fontawesome -->
	<link rel="stylesheet" href="${rc.contextPath}/assets/css/bootstrap.min.css" />
	<link rel="stylesheet" href="${rc.contextPath}/assets/font-awesome/4.5.0/css/font-awesome.min.css" />
	<!-- page specific plugin styles -->
	<link rel="stylesheet" href="${rc.contextPath}/assets/css/jquery.gritter.min.css" />
	<!-- text fonts -->
	<link rel="stylesheet" href="${rc.contextPath}/assets/css/fonts.googleapis.com.css" />
	<!-- ace styles -->
	<link rel="stylesheet" href="${rc.contextPath}/assets/css/ace.min.css" class="ace-main-stylesheet" id="main-ace-style" />
	<link rel="stylesheet" href="${rc.contextPath}/assets/css/ace-skins.min.css" />
	<link rel="stylesheet" href="${rc.contextPath}/assets/css/ace-rtl.min.css" />
	
	<link rel="stylesheet" href="${rc.contextPath}/stylesheets/daterangepicker.css">
</head>
<body class="skin-2" style="background-color: #FFF;">
	<div class="page-content">
		<div class="page-header">
			<h1>
				订单转化率
			</h1>
		</div>
		<div class="row">
			<div class="col-xs-12">
				<div id="dynamic-table_wrapper" class="dataTables_wrapper form-inline no-footer">
					<form class="form-inline" action="${rc.contextPath}/push/exportData" method="post">
						<div class="col-xs-2">
							<div class="dataTables_length">
								<label>推送对象
									<select id="pushObject" name="pushObject" onchange="objectChange()" aria-controls="dynamic-table" class="form-control input-sm">  
								    	<option value="all">全部</option>
										<option value="NORMAL">普通推送</option>  
										<option value="PAY_ORDER">订单催支付</option>  
										<option value="ACCURATE_ORDER">订单行为推送</option>  
										<option value="COUPON">优惠券推送</option>
										<option value="TICKET_TRAVEL">门票出行推送</option>
										<option value="TICKET_COMMENT">门票点评推送</option>     
						           </select> 
								</label>
							</div>
						</div>
						<div class="col-xs-2" id="pushIDDiv">
							<div class="dataTables_length">
								<label>推送任务ID
									<input type="text" class="form-control" id="pushID" name="pushID" placeholder="推送任务ID">
			    					<span id="tishi" style="color:red">推送任务ID为纯数字</span>
								</label>
							</div>
						</div>
						<div class="col-xs-2">
							<div class="dataTables_length">
								<label>选择时段
									<input class="form-control" type="text" id="config-demo" name="btime"/>
								</label>
							</div>
						</div>
						<div class="col-xs-2">
							<div class="dataTables_length">
								<label>推送终端
									<input type="radio" name="pushTerminal" value="all" checked="checked">全部&nbsp;&nbsp;
								    <input type="radio" name="pushTerminal" value="ANDROID">Android&nbsp;&nbsp;
								    <input type="radio" name="pushTerminal" value="IPHONE">iOS
								    <input type="text" id="currentPage" name="pageNum" hidden="true" value="1">
								    <input type="text" id="totalPages" hidden="true">
								</label>
							</div>
						</div>
						<div class="col-xs-2">
							<div class="dataTables_length">
								<button type="button" class="btn btn-pink btn-sm" id="generateBtn">
									<span class="ace-icon fa fa-search icon-on-right bigger-110"></span>
									查询
								</button>
							</div>
						</div>
						<div class="col-xs-2">
							<div class="dataTables_length">
								<button type="button" class="btn btn-pink btn-sm" id="exportExcel">
									导出xls文件
								</button>
							</div>
						</div>
					</form>
					<table id="dynamic-table" class="table table-striped table-bordered table-hover dataTable no-footer" role="grid" aria-describedby="dynamic-table_info">
						<thead>
							<tr>
								<th>日期</th>
								<th>推送总量</th>
								<th>送达</th>
								<th>点击</th>
								<th>下单数</th>
								<th>下单金额</th>
								<th>支付单</th>
								<th>支付金额</th>
							</tr>
						</thead>
						<tbody>
						</tbody>
					</table>
				</div>
			</div>
		</div>
	</div>
	<script src="${rc.contextPath}/assets/js/jquery-2.1.4.min.js"></script>
	<script type="text/javascript">
		if('ontouchstart' in document.documentElement) document.write("<script src='${rc.contextPath}/assets/js/jquery.mobile.custom.min.js'>"+"<"+"/script>");
	</script>
	<script src="${rc.contextPath}/assets/js/bootstrap.min.js"></script>

	<!-- page specific plugin scripts -->
	<script type="text/javascript" src="${rc.contextPath}/javascripts/moment.js"></script>
	<script type="text/javascript" src="${rc.contextPath}/javascripts/daterangepicker.js"></script>
	<!-- ace scripts -->
	<script src="${rc.contextPath}/assets/js/jquery.gritter.min.js"></script>
	<script src="${rc.contextPath}/assets/js/ace-elements.min.js"></script>
	<script src="${rc.contextPath}/assets/js/ace.min.js"></script>
    <script type="text/javascript">
   		jQuery(function($) {
				$('input[name=btime]').daterangepicker({
						startDate: new Date(new Date().getTime()-1*1000*60*60*24),
					    endDate: new Date(new Date().getTime()-1*1000*60*60*24),
						/* startDate: new Date(new Date().getTime()-7*1000*60*60*24),
					    endDate: new Date(new Date().getTime()-1*1000*60*60*24), */
					    showDropdowns : true,  
			            showWeekNumbers : false,
			            timePicker : false,
			            timePicker12Hour : false,
			            ranges : {  
			            	'昨日': [moment().subtract(1, 'days'), moment().subtract(1, 'days')],
			            	'最近7日': [moment().subtract(7, 'days'), moment().subtract(1, 'days')],  
			                '最近30日': [moment().subtract(30, 'days'), moment().subtract(1, 'days')],
			                '最近90日': [moment().subtract(90, 'days'), moment().subtract(1, 'days')]
			            },
			            opens : 'right',  
			            buttonClasses : [ 'btn btn-default' ],  
			            applyClass : 'btn-small btn-pink',  
			            cancelClass : 'btn-small',  
			            format : 'yyyy-MM-dd',
			            separator : ' to ',
			            locale : {  
			                applyLabel : '确定',  
			                cancelLabel : '取消',  
			                fromLabel : '起始时间',  
			                toLabel : '结束时间',  
			                customRangeLabel : '自定义',  
			                daysOfWeek : [ '日', '一', '二', '三', '四', '五', '六' ],  
			                monthNames : [ '一月', '二月', '三月', '四月', '五月', '六月',  
			                        '七月', '八月', '九月', '十月', '十一月', '十二月' ],  
			                firstDay : 1  
			            }
					},
					function(start, end, label) {//格式化日期显示框  
			            
			            $('#chooseTime').html(start.format('yyyy-MM-dd') + ' - ' + end.format('yyyy-MM-dd'));  
			       });
				$("table").hide();
			});
		   var objectChange=function(){
			   if($("#pushObject").val()=="NORMAL"){
				   $("#pushIDDiv").show();
			   }else{
			   	$("#pushIDDiv").hide();
			   }
		   };
   			function go(pageNum){
			     if(parseInt(pageNum)!=pageNum||parseInt(pageNum)<=0){
			    	 return ;
			     }
			     var totalPages=$("#totalPages").val();
			     if(parseInt(pageNum)>parseInt(totalPages)){
			    	 return ;
			     }
			  
			     $("#currentPage").val(pageNum);
			     $("#generateBtn").click();
			}
   	</script>
	<script type="text/javascript">
	$(document).ready(function(event) {
		$("#tishi").hide();
		$("#exportExcel").hide();
		
		if($("#pushObject").val()=="NORMAL"){
			   $("#pushIDDiv").show();
		   }else{
		   	$("#pushIDDiv").hide();
		   }
		
		$("#pushID").blur(function(){
			var pushID=$("#pushID").val();
			if(pushID!=null&&pushID!=""){
			 if(parseInt(pushID)!=pushID||parseInt(pushID)<=0){
		    	 $("#tishi").show() ;
		     }else{
		    	 $("#tishi").hide() ;
		     }}
		});
		$("#generateBtn").click(function(){
			var pushObject=$("#pushObject").val();
			var pushID=$("#pushID").val();
			var btime=$("#config-demo").val();
			var currentPage=$("#currentPage").val();
			var pushTerminal=$("input[name='pushTerminal']:checked").val();
				$.ajax({
					  data: "pushObject="+pushObject+"&pushID="+pushID+"&btime="+btime+"&pushTerminal="+pushTerminal+"&pageNum="+currentPage,
					  url: "${rc.contextPath}/push/ajaxData",
					  success: function(data){
					    if(data==null||data==""||data.pushListSize==0||data.pageInfo==null){
					    	window.location.href="${rc.contextPath}/page/404";
					    	return;
					    }else{
					    	$("#exportExcel").show();
					    	$("table").show();
					    	$("#data").empty();
					    	var dataList=data.pushList;
					    	var pageBar=data.pageBar;
					    	var pageInfo1=data.pageInfo;
					    	$("#totalPages").val(pageInfo1.pages);
					    	for(i=0;i<data.pushList.length;i++){
					    	var html="<tr><td>"+ new Date(dataList[i].createTime).format('yyyy-MM-dd')+"</td>"+"<td>"+dataList[i].pushTotalCount+"</td>"+"<td>"+dataList[i].pushDeliverCount+"</td>"
					    	+"<td>"+dataList[i].pushClickCount+"</td>"+"<td>"+dataList[i].orderCount+"</td>"+"<td>"+dataList[i].orderAmount+"</td>"+
					    	"<td>"+dataList[i].payCount+"</td>"+"<td>"+dataList[i].payAmount+"</td></tr>";
					    	$("#data").append(html);
					    	}
					    	var html1="当前页码:&nbsp;&nbsp;"+pageInfo1.pageNum+"/"+pageInfo1.pages+"&nbsp;&nbsp;页"+"&nbsp;&nbsp;&nbsp;&nbsp;"
					    				+"<a href='javascript:void(0)' onclick='go(1)'>首页</a>"
					    				+"&nbsp;&nbsp;&nbsp;&nbsp;<a href='javascript:void(0)' onclick='go("+pageInfo1.prePage+")'>上一页</a>&nbsp;";
					    	var html2="";
					    	for(t=0;t<pageBar.length;t++){
					    		html2+="&nbsp;&nbsp;<a href='javascript:void(0)' onclick='go("+pageBar[t]+")'>"+pageBar[t]+"</a>&nbsp;&nbsp;";
					    	}
					    	html1=html1+html2;
					    	var html3="&nbsp;&nbsp;<a href='javascript:void(0)' onclick='go("+pageInfo1.nextPage+")'>下一页</a>"
					    				+"&nbsp;&nbsp;<a href='javascript:void(0)' onclick='go("+pageInfo1.lastPage+")'>尾页</a>&nbsp;&nbsp;"
					    				+"<input type='text' value='"+pageInfo1.pageNum+"' id='num' style='width:25px'>&nbsp;&nbsp;";
					    	html1=html1+html3;
					    	$("#pagination").empty();		
					    	$("#pagination").append(html1);
					    	$("#pagination").append("<input type='button' value='确认' onclick='go(document.getElementById(&apos;num&apos;).value);'>");
					    }
					 }
				});
			});
		});
	</script>
</body>
</html>